<?php
/**
 * Helper to build chapter order
 *
 * PHP versions 4 and 5
 *
 * TutoriumBase (http://tutoriumbase.my-reality.de)
 * Copyright 2012, Miguel Gonzalez (http://my-reality.de)
 *
 *
 * @copyright     Copyright 2012, Miguel Gonzalez (http://my-reality.de)
 * @link          http://tutoriumbase.my-reality.de TutoriumBase
 * @since         TutoriumBase v 0.1
 */

class ChapterHelper extends AppHelper {

    
    /**
     * Function that builds a full chapter array
     *
     * @author Miguel Gonzalez
     *
     * @param <array> $data data of the entire tutorial
     * @param <bool> $edit special functionality for edit
     *
     * @return <array> 
     */
    function buildOrder($data, $edit = false) {
        $return_arr = array();

        if ($edit) {
            for ($i = 1; $i <= count($data); ++$i) {
                    $return_arr[$i] = $i . '. Position: ' . $data[$i-1]['caption'];
            }
        } else {
            for ($i = 1; $i <= count($data) + 1; ++$i) {
                if ($i <= count($data)) {
                    $return_arr[$i] = $i . '. Position: ' . $data[$i-1]['caption'];
                } else {
                    $return_arr[$i] = 'Standardposition';
                }
            }
        }
        
        return $return_arr;
    }
    
}

?>